home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-08-16 | 23.7 KB | 866 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: SLWindow.cpp
- // Release Version: $ ODF 1 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWOS.hpp"
-
- #ifndef SLWINDOW_H
- #include "SLWindow.h"
- #endif
-
- #ifndef FWPRIMEM_H
- #include "FWPriMem.h"
- #endif
-
- #ifndef FWMEMORY_H
- #include "FWMemory.h"
- #endif
-
- #ifndef FWRESOUR_H
- #include "FWResour.h"
- #endif
-
- #ifndef FWGRUTIL_H
- #include "FWGrUtil.h"
- #endif
-
- #ifndef FWFCTINF_H
- #include "FWFctInf.h"
- #endif
-
- #ifndef FWACQUIR_H
- #include "FWAcquir.h"
- #endif
-
- #ifndef FWSTRING_H
- #include "FWString.h"
- #endif
-
- #ifndef SLMIXOS_H
- #include "SLMixOS.h"
- #endif
-
- #if defined(FW_BUILD_MAC) && !defined(FWMACOS_H)
- #include "SLMacOS.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef _ITEXT_
- #include "IText.h"
- #endif
-
- #ifndef SOM_ODWindow_xh
- #include <Window.xh>
- #endif
-
- #if defined(FW_BUILD_MAC) & !defined(__RESOURCES__)
- #include <Resources.h>
- #endif
-
- //========================================================================================
- // Runtime Info
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment fwtoolbx
- #endif
-
- //========================================================================================
- // defines
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #define FW_kSystem75WindoidWDEF 1985 // System 7.5 windoid
- #define FW_kNonSystem75WindoidWDEF 48 // System 7.5 windoid (for system < 7.5)
- #define FW_kSystem75ToggleTBar 1 // Bit 0 tell us whether to hilite/unhilite the tittle bar
- #define FW_kSystem75HasGrow 2 // Bit 1 is the grow bit
- #define FW_kSystem75HasZoom 4 // Bit 2 is the zoom bit
- #define FW_kSystem75VertTBar 8 // bit 3 is for a vertical tittle bar
- #endif
-
- //========================================================================================
- // Global Members
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- Handle FW_gMacFloatWindowProc = NULL;
- #endif
-
- //========================================================================================
- // Window Utilities
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_PrivFitRect
- //----------------------------------------------------------------------------------------
- // return:
- // 0: nothing changed
- // 1: position changed
- // 2: size changed
- // 3: position and size changed
-
- static short FW_PrivFitRect(const FW_CRect& containingRect, FW_CRect& rect)
- {
- // This static function needs no try block - Do not throw!
- short changed = 0;
-
- // ----- Be sure that it fits on the screen -----
- if (rect.left < containingRect.left)
- {
- changed |= 0x0001;
- rect.Offset(containingRect.left - rect.left, FW_kFixed0);
- }
-
- if (rect.top < containingRect.top)
- {
- changed |= 0x0001;
- rect.Offset(FW_kFixed0, containingRect.top - rect.top);
- }
-
- if (rect.right > containingRect.right)
- {
- changed |= 0x0001;
- rect.Offset(containingRect.right - rect.right, FW_kFixed0);
- if (rect.left < containingRect.left)
- {
- changed |= 0x0002;
- rect.left = containingRect.left;
- }
- }
-
- if (rect.bottom > containingRect.bottom)
- {
- changed |= 0x0001;
- rect.Offset(FW_kFixed0, containingRect.bottom - rect.bottom);
- if (rect.top < containingRect.top)
- {
- changed |= 0x0002;
- rect.top = containingRect.top;
- }
- }
-
- return changed;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_SetWindowSize
- //----------------------------------------------------------------------------------------
-
- void SL_API FW_SetWindowSize(ODPlatformWindow platformWindow, const FW_SPoint& interiorSize, FW_PlatformError* error)
- {
- // No try block necessary - Do not throw
- *error = FW_xNoError;
-
- #ifdef FW_BUILD_MAC
- ::SizeWindow(platformWindow, FW_FixedToInt(interiorSize.x), FW_FixedToInt(interiorSize.y), TRUE);
- #endif
-
- #ifdef FW_BUILD_WIN
- FW_CRect borderSize;
- FW_GetWindowBorderSize(platformWindow, borderSize, error);
- if (*error)
- return;
-
- FW_CPlatformRect windowRect;
- ::GetWindowRect(platformWindow, &windowRect);
-
- int width = FW_FixedToInt(interiorSize.x + borderSize.left + borderSize.right);
- int height = FW_FixedToInt(interiorSize.y + borderSize.top + borderSize.bottom);
-
- ::MoveWindow(platformWindow, //::GetParent(platformWindow),
- windowRect.left, windowRect.top,
- width, height,
- TRUE);
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_SetWindowPosition
- //----------------------------------------------------------------------------------------
-
- void SL_API FW_SetWindowPosition(ODPlatformWindow platformWindow, const FW_SPoint& newPosition, FW_PlatformError* error)
- {
- // No try block necessary - Do not throw
- *error = FW_xNoError;
-
- #ifdef FW_BUILD_MAC
- FW_CRect borderSize;
- FW_GetWindowBorderSize(platformWindow, borderSize, error);
- if (*error)
- return;
-
- ::MoveWindow(platformWindow, FW_FixedToInt(newPosition.x + borderSize.left), FW_FixedToInt(newPosition.y + borderSize.top), FALSE);
- #endif
-
- #ifdef FW_BUILD_WIN
- FW_CPlatformRect windowRect;
- ::GetWindowRect(platformWindow, &windowRect);
-
- ::MoveWindow(platformWindow, //::GetParent(platformWindow),
- FW_FixedToInt(newPosition.x), FW_FixedToInt(newPosition.y),
- windowRect.right - windowRect.left,
- windowRect.bottom - windowRect.top,
- FALSE);
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PositionModalDialog
- //----------------------------------------------------------------------------------------
-
- void SL_API FW_PositionModalDialog(ODPlatformWindow platformWindow, FW_PlatformError* error)
- {
- // No try block necessary - Do not throw
- *error = FW_xNoError;
-
- #ifdef FW_BUILD_MAC
- FW_CPoint exteriorSize;
- exteriorSize.x = FW_IntToFixed(platformWindow->portRect.right - platformWindow->portRect.left);
- exteriorSize.y = FW_IntToFixed(platformWindow->portRect.bottom - platformWindow->portRect.top);
-
- FW_CRect borderSize;
- FW_GetWindowBorderSize(platformWindow, borderSize, error);
- if (*error)
- return;
-
- exteriorSize.x += borderSize.left + borderSize.right;
- exteriorSize.y += borderSize.top + borderSize.bottom;
-
- FW_CRect dialogRect(FW_kFixed0, FW_kFixed0, exteriorSize.x, exteriorSize.y);
- #endif
-
- #ifdef FW_BUILD_WIN
- FW_CPlatformRect windowRect;
- ::GetWindowRect(platformWindow, &windowRect);
- FW_CRect dialogRect(windowRect);
- #endif
-
- FW_CenterRectOnScreen(dialogRect, TRUE, TRUE, TRUE);
-
- FW_SetWindowPosition(platformWindow, dialogRect.TopLeft(), error);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_FitWindowToScreen
- //----------------------------------------------------------------------------------------
-
- FW_Boolean SL_API FW_FitWindowToScreen(ODPlatformWindow platformWindow, FW_PlatformError* error)
- {
- // No try block necessary - Do not throw
- *error = FW_xNoError;
-
- FW_CRect border;
- FW_GetWindowBorderSize(platformWindow, border, error);
- if (*error)
- return false;
-
- #ifdef FW_BUILD_MAC
- FW_CRect screenRect;
- ::FW_MacGetMaxIntersectedDevice(platformWindow, screenRect, error);
- if (*error)
- return false;
- screenRect.Inset(FW_IntToFixed(3), FW_IntToFixed(3)); // leave space around window structure area
- #endif
-
- #ifdef FW_BUILD_WIN
- FW_CPlatformRect plScreenRect;
- ::GetWindowRect(::GetDesktopWindow(), &plScreenRect);
- FW_CRect screenRect(plScreenRect);
- #endif
-
- #ifdef FW_BUILD_MAC
- FW_CPoint windowPos, windowSize;
-
- FW_GetWindowPosition(platformWindow, windowPos, error);
- if (*error)
- return false;
-
- FW_GetWindowSize(platformWindow, windowSize, error);
- if (*error)
- return false;
-
- FW_CRect windowRect(windowPos.x,
- windowPos.y,
- windowPos.x + windowSize.x + border.left + border.right,
- windowPos.y + windowSize.y + border.top + border.bottom);
- #endif
-
- #ifdef FW_BUILD_WIN
- FW_CPlatformRect plWindowRect;
- ::GetWindowRect(platformWindow, &plWindowRect);
- FW_CRect windowRect(plWindowRect);
- #endif
-
- short changed = FW_PrivFitRect(screenRect, windowRect);
-
- if ((changed & 0x0001) != 0)
- {
- FW_SetWindowPosition(platformWindow, windowRect.TopLeft(), error);
- if (*error)
- return false;
- }
-
- if ((changed & 0x0002) != 0)
- {
- FW_CPoint windowSize(windowRect.Width() - border.left - border.right,
- windowRect.Height() - border.top - border.bottom);
- FW_SetWindowSize(platformWindow, windowSize, error);
- }
-
- return (changed != 0);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_GetWindowSize
- //----------------------------------------------------------------------------------------
-
- void SL_API FW_GetWindowSize(ODPlatformWindow platformWindow, FW_SPoint& interiorSize, FW_PlatformError* error)
- {
- // No try block necessary - Do not throw
- *error = FW_xNoError;
-
- #ifdef FW_BUILD_MAC
- interiorSize.x = FW_IntToFixed(platformWindow->portRect.right - platformWindow->portRect.left);
- interiorSize.y = FW_IntToFixed(platformWindow->portRect.bottom - platformWindow->portRect.top);
- #endif
-
- #ifdef FW_BUILD_WIN
- FW_CPlatformRect windowRect;
- ::GetWindowRect(platformWindow, &windowRect);
-
- FW_CRect borderSize;
- FW_GetWindowBorderSize(platformWindow, borderSize, error);
- // if error let go
-
- interiorSize.x = FW_IntToFixed(windowRect.right - windowRect.left) - borderSize.left - borderSize.right;
- interiorSize.y = FW_IntToFixed(windowRect.bottom - windowRect.top) - borderSize.top - borderSize.bottom;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_GetWindowPosition
- //----------------------------------------------------------------------------------------
-
- void SL_API FW_GetWindowPosition(ODPlatformWindow platformWindow, FW_SPoint& position, FW_PlatformError* error)
- {
- // No try block necessary - Do not throw
- *error = FW_xNoError;
-
- #ifdef FW_BUILD_MAC
- GrafPtr curPort;
- ::GetPort(&curPort);
- ::SetPort(platformWindow);
- Point localToGlobal = {platformWindow->portRect.top, platformWindow->portRect.left};
- ::LocalToGlobal(&localToGlobal);
- ::SetPort(curPort);
-
- FW_CRect borderSize;
- FW_GetWindowBorderSize(platformWindow, borderSize, error);
- // if error let go
-
- position.x = FW_IntToFixed(localToGlobal.h) - borderSize.left;
- position.y = FW_IntToFixed(localToGlobal.v) - borderSize.top;
- #endif
-
- #ifdef FW_BUILD_WIN
- FW_CPlatformRect windowRect;
- ::GetWindowRect(platformWindow, &windowRect);
-
- position.x = FW_IntToFixed(windowRect.left);
- position.y = FW_IntToFixed(windowRect.top);
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_GetWindowTitle
- //----------------------------------------------------------------------------------------
- // windowTitle must have a valid buffer
-
- void SL_API FW_GetWindowTitle(ODPlatformWindow platformWindow, FW_HString* windowTitleRep, FW_PlatformError* error)
- {
- FW_ERR_TRY
- {
- FW_CString windowTitle(*windowTitleRep);
-
- #ifdef FW_BUILD_MAC
- Str255 title;
- ::GetWTitle(platformWindow, title);
- windowTitle.ReplaceAll(title);
- #endif
-
- #ifdef FW_BUILD_WIN
- char title[256];
- ::GetWindowText(platformWindow, title, 256);
- windowTitle = title;
- #endif
- }
- FW_ERR_CATCH
- }
-
- //----------------------------------------------------------------------------------------
- // FW_SetWindowTitle
- //----------------------------------------------------------------------------------------
-
- void SL_API FW_SetWindowTitle(ODPlatformWindow platformWindow, FW_HString windowTitleRep, FW_PlatformError* error)
- {
- FW_ERR_TRY
- {
- FW_CString windowTitle(windowTitleRep);
-
- #ifdef FW_BUILD_MAC
- Str255 title;
- windowTitle.ExportPascal(title);
- ::SetWTitle(platformWindow, title);
- #endif
-
- #ifdef FW_BUILD_WIN
- FW_CAcquireNulTerminatedString string(windowTitle);
- ::SetWindowText(platformWindow, string);
- #endif
- }
- FW_ERR_CATCH
- }
-
- //----------------------------------------------------------------------------------------
- // FW_GetWindowBorderSize
- //----------------------------------------------------------------------------------------
- // Returns the size of the border in pixels
-
- void SL_API FW_GetWindowBorderSize(ODPlatformWindow platformWindow, FW_SRect &borderSize, FW_PlatformError* error)
- {
- // No try block necessary - Do not throw
- *error = FW_xNoError;
-
- FW_ASSERT(platformWindow != NULL);
-
- #ifdef FW_BUILD_MAC
- WindowRecord *windowRec = (WindowRecord*)platformWindow;
-
- FW_Boolean rgnsWereBuilt = FW_PrivMacBuildWindowRegions(platformWindow, TRUE, error);
- if (*error)
- return;
- FW_CPlatformRect outside = (*windowRec->strucRgn)->rgnBBox;
- FW_CPlatformRect inside = (*windowRec->contRgn)->rgnBBox;
- FW_PrivMacBuildWindowRegions(platformWindow, rgnsWereBuilt, error);
- // if error just let go
- #endif
-
- #ifdef FW_BUILD_WIN
- DWORD dwStyle = (DWORD)::GetWindowLong(platformWindow, GWL_STYLE);
- DWORD dwExStyle = (dwStyle & DS_MODALFRAME) ? WS_EX_DLGMODALFRAME : 0L;
-
- FW_CPlatformRect inside;
- ::GetClientRect(platformWindow, &inside);
-
- FW_CPlatformRect outside(inside.left, inside.top, inside.right, inside.bottom);
-
- ::AdjustWindowRectEx(&outside, dwStyle ^ DS_MODALFRAME, FALSE, dwExStyle);
- #endif
-
- borderSize.left = FW_IntToFixed(inside.left - outside.left);
- borderSize.top = FW_IntToFixed(inside.top - outside.top);
- borderSize.right = FW_IntToFixed(outside.right - inside.right);
- borderSize.bottom = FW_IntToFixed(outside.bottom - inside.bottom);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_WindowToScreen
- //----------------------------------------------------------------------------------------
-
- FW_PlatformError SL_API FW_WindowToScreen(ODPlatformWindow platformWindow,
- FW_SPoint* points,
- unsigned short nbPoint)
- {
- // No try block necessary - Do not throw
- FW_ASSERT(nbPoint > 1);
-
- FW_CPoint* casted = (FW_CPoint*)points;
-
- #ifdef FW_BUILD_MAC
- GrafPtr curPort;
- ::GetPort(&curPort);
- ::SetPort(platformWindow);
-
- FW_CPlatformPoint plfmPoint;
- if (nbPoint == 1)
- {
- plfmPoint = *points;
- ::LocalToGlobal(&plfmPoint);
- *casted = plfmPoint;
- }
- else
- {
- for (unsigned short i = 0; i<nbPoint; i++)
- {
- plfmPoint = casted[i];
- ::LocalToGlobal(&plfmPoint);
- casted[i] = plfmPoint;
- }
- }
-
- ::SetPort(curPort);
- #endif
-
- #ifdef FW_BUILD_WIN
- FW_DEBUG_MESSAGE("Not yet implemented");
- #endif
-
- return FW_xNoError;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_ScreenToWindow
- //----------------------------------------------------------------------------------------
-
- FW_PlatformError SL_API FW_ScreenToWindow(ODPlatformWindow platformWindow,
- FW_SPoint* points,
- unsigned short nbPoint)
- {
- // No try block necessary - Do not throw
- FW_ASSERT(nbPoint > 1);
-
- FW_CPoint* casted = (FW_CPoint*)points;
-
- #ifdef FW_BUILD_MAC
- GrafPtr curPort;
- ::GetPort(&curPort);
- ::SetPort(platformWindow);
-
- FW_CPlatformPoint plfmPoint;
- if (nbPoint == 1)
- {
- plfmPoint = *points;
- ::GlobalToLocal(&plfmPoint);
- *casted = plfmPoint;
- }
- else
- {
- for (unsigned short i = 0; i<nbPoint; i++)
- {
- plfmPoint = casted[i];
- ::GlobalToLocal(&plfmPoint);
- casted[i] = plfmPoint;
- }
- }
-
- ::SetPort(curPort);
- #endif
-
- #ifdef FW_BUILD_WIN
- FW_DEBUG_MESSAGE("Not yet implemented");
- #endif
-
- return FW_xNoError;
- }
-
- #ifdef FW_BUILD_MAC
- //---------------------------------------------------------------------------------------
- // FW_PrivMacCreatePlatformWindow
- //---------------------------------------------------------------------------------------
- // position is the inside position
-
- ODPlatformWindow FW_PrivMacCreatePlatformWindow(Environment* ev,
- Str255 windowTitle,
- const FW_SPoint& interiorSize,
- const FW_SPoint& position,
- unsigned short procID,
- FW_Boolean hasCloseBox,
- long refCon)
- {
- ODPlatformWindow platformWindow = NULL;
-
- FW_SOM_TRY
- {
- FW_CAcquireCFMResourceAccess qr(ev);
- FW_CPlatformRect windowRect(FW_FixedToInt(position.x), FW_FixedToInt(position.y),
- FW_FixedToInt(position.x) + FW_FixedToInt(interiorSize.x),
- FW_FixedToInt(position.y) + FW_FixedToInt(interiorSize.y));
-
- Handle windowProc = ::GetResource('WDEF', procID >> 4); // Force load of the resource
- platformWindow = ::NewCWindow(NULL,
- &windowRect,
- windowTitle,
- FALSE,
- procID,
- (WindowPtr)-1L,
- hasCloseBox,
- refCon);
-
- // Special case with floating windows under system < 7.5
- if ((procID & 0xFFF0) == FW_kNonSystem75WindoidWDEF)
- {
- if (FW_gMacFloatWindowProc == NULL)
- {
- FW_gMacFloatWindowProc = ((WindowPeek)platformWindow)->windowDefProc;
- ::DetachResource(FW_gMacFloatWindowProc);
- }
- else
- {
- Handle temp = ((WindowPeek)platformWindow)->windowDefProc;
- ((WindowPeek)platformWindow)->windowDefProc = FW_gMacFloatWindowProc;
- ::ReleaseResource(temp);
- }
- }
- }
- FW_SOM_CATCH
-
- return platformWindow;
- }
- #endif
-
- #ifdef FW_BUILD_MAC
- //----------------------------------------------------------------------------------------
- // FW_PrivMacTrackResizeWindow
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_PrivMacTrackResizeWindow(ODPlatformWindow platformWindow,
- const FW_SRect& growLimits,
- FW_SPlatformPoint startPoint,
- FW_PlatformError* error)
- {
- FW_CPoint currentSize;
- ::FW_GetWindowSize(platformWindow, currentSize, error);
- if (*error)
- return false;
-
- FW_CPlatformRect plfmGrowLimits(growLimits);
- long newWindowSize = ::GrowWindow(platformWindow, startPoint, &plfmGrowLimits);
-
- if (newWindowSize != 0)
- {
- FW_CPoint interiorSize(FW_IntToFixed(LoWord(newWindowSize)), FW_IntToFixed(HiWord(newWindowSize)));
- FW_SetWindowSize(platformWindow, interiorSize, error);
- return *error == FW_xNoError;
- }
- else
- return FALSE;
- }
- #endif
-
- #ifdef FW_BUILD_MAC
- //----------------------------------------------------------------------------------------
- // FW_PrivMacDoZoom
- //----------------------------------------------------------------------------------------
-
- void FW_PrivMacDoZoom(ODPlatformWindow platformWindow,
- const FW_SPoint& zoomedSize,
- const FW_SRect& borderSize,
- const FW_SRect& screenRect,
- unsigned long message,
- FW_PlatformError* error)
- {
- // No try block necessary - Do not throw
- *error = FW_xNoError;
-
- if (message == inZoomOut)
- {
- // ----- Calculate the outside bounds of the window -----
- FW_CPoint windowPos;
- FW_GetWindowPosition(platformWindow, windowPos, error);
- if (*error)
- return;
-
- FW_CRect windowRect(windowPos.x,
- windowPos.y,
- windowPos.x + zoomedSize.x + borderSize.left + borderSize.right,
- windowPos.y + zoomedSize.y + borderSize.top + borderSize.bottom);
-
- // ----- Be sure that it fits on the screen -----
- FW_PrivFitRect(screenRect, windowRect);
-
- // ----- Calculate the inside -----
- windowRect.left += borderSize.left;
- windowRect.right -= borderSize.right;
- windowRect.top += borderSize.top;
- windowRect.bottom -= borderSize.bottom;
-
- // ----- and set the stdState -----
- (*((WStateDataHandle)(((WindowPeek)platformWindow)->dataHandle)))->stdState = windowRect.AsPlatformRect();
- }
-
- *error =::FW_MacZoomWindow(platformWindow, message == inZoomIn);
- }
- #endif
-
- #ifdef FW_BUILD_MAC
- //----------------------------------------------------------------------------------------
- // FW_PrivMacStyleToProcId
- //----------------------------------------------------------------------------------------
-
- unsigned short FW_PrivMacStyleToProcId(FW_WindowStyle windowStyle)
- {
- // No try block necessary - Do not throw
- unsigned short procId;
-
- if (windowStyle & FW_kStandardWindow)
- {
- if (windowStyle & FW_kResizeable)
- if (windowStyle & FW_kHasMaximizeBox)
- procId = zoomDocProc;
- else
- procId = documentProc;
- else if (windowStyle & FW_kHasMaximizeBox)
- procId = zoomNoGrow;
- else
- procId = noGrowDocProc;
- }
- else if (windowStyle & FW_kModelessDialog)
- {
- procId = documentProc;
- }
- else if (windowStyle & FW_kModalDialog)
- {
- if (windowStyle & FW_kHasCaption)
- procId = movableDBoxProc;
- else
- procId = dBoxProc;
-
- }
- else if (windowStyle & FW_kFloatingWindow)
- {
- // Check first if we have the system 7.5 resource
- Handle hld = ::GetResource('WDEF', 124);
- if (hld == NULL)
- procId = FW_kNonSystem75WindoidWDEF;
- else
- procId = FW_kSystem75WindoidWDEF;
-
- if (windowStyle & FW_kHasMaximizeBox)
- procId += FW_kSystem75HasZoom;
- if (windowStyle & FW_kResizeable)
- procId += FW_kSystem75HasGrow;
- }
- // else if (windowStyle & FW_kMacDesktopPane)
- // {
- // procId = plainDBox;
- // }
- else
- {
- FW_ASSERT(FALSE);
- procId = documentProc;
- }
-
- return procId;
- }
- #endif
-
- #ifdef FW_BUILD_WIN
- //----------------------------------------------------------------------------------------
- // FW_PrivWindStyleToWindowsFlags
- //----------------------------------------------------------------------------------------
-
- DWORD SL_API FW_PrivWindStyleToWindowsFlags(FW_WindowStyle style, FW_PlatformError* error)
- {
- // No try block necessary - Do not throw
- *error = FW_xNoError;
-
- DWORD dwStyle = 0;
-
- if (style & FW_kStandardWindow)
- dwStyle |= WS_CHILD;
- else if (style & FW_kOverlappedWindow)
- dwStyle |= WS_OVERLAPPED;
- else if (style & FW_kFloatingWindow)
- dwStyle |= /*WS_POPUP |*/ WS_CAPTION;
- else if (style & FW_kModelessDialog)
- dwStyle |= (WS_POPUP | DS_MODALFRAME);
- else if (style & FW_kModalDialog)
- dwStyle |= (WS_POPUP | DS_MODALFRAME);// DS_MODALFRAME will be transform into WS_EX_DLGMODALFRAME
- else
- FW_ASSERT(FALSE);
-
- if (style & FW_kResizeable)
- dwStyle |= WS_THICKFRAME;
-
- if (style & FW_kHasCaption)
- dwStyle |= WS_CAPTION;
-
- if (style & FW_kHasCloseBox)
- dwStyle |= WS_SYSMENU;
-
- if (style & FW_kHasMinimizeBox)
- dwStyle |= WS_MINIMIZEBOX;
-
- if (style & FW_kHasMaximizeBox)
- dwStyle |= WS_MAXIMIZEBOX;
-
- return dwStyle;
- }
- #endif
-
- #ifdef FW_BUILD_WIN
- //----------------------------------------------------------------------------------------
- // FW_PrivWindFixSystemMenu
- //----------------------------------------------------------------------------------------
- // Makes system menu consistent with platform dialogs
-
- void SL_API FW_PrivWindFixSystemMenu(FW_WindowStyle windowStyle, FW_PlatformError* error)
- {
- #if 0
- // No try block necessary - Do not throw
- *error = FW_xNoError;
-
- // Make system menu standard for windows dialogs
- HMENU fMenuHandle = ::GetSystemMenu(GetPlatformWindow(), FALSE);
-
- if (fMenuHandle != NULL)
- {
- BR_CBedrock* bedrock = BR_CBedrock::GetBedrock();
- BR_CCharString255 MenuText;
-
- // Delete all items
- while (::DeleteMenu(fMenuHandle, 0, MF_BYPOSITION))
- ;
-
- // Flags for ::AppendMenu()
- const WORD wfItemFlags = MF_BYCOMMAND | MF_ENABLED | MF_STRING;
-
- // Add in dialog menu
- if (windowStyle & (kHasMinimizeBox | FW_kHasMaximizeBox))
- {
- bedrock->LoadString(IDSL_SYSTEMMENU, IDS_RESTORE, MenuText);
- ::AppendMenu(fMenuHandle, wfItemFlags, SC_RESTORE, MenuText);
- }
-
-
- {
- bedrock->LoadString(IDSL_SYSTEMMENU, IDS_MOVE, MenuText);
- ::AppendMenu(fMenuHandle, wfItemFlags, SC_MOVE, MenuText);
- }
-
- if (windowStyle & FW_kResizeable)
- {
- bedrock->LoadString(IDSL_SYSTEMMENU, IDS_SIZE, MenuText);
- ::AppendMenu(fMenuHandle, wfItemFlags, SC_SIZE, MenuText);
- }
-
- if (windowStyle & FW_kHasMinimizeBox)
- {
- bedrock->LoadString(IDSL_SYSTEMMENU, IDS_MINIMIZE, MenuText);
- ::AppendMenu(fMenuHandle, wfItemFlags, SC_MINIMIZE, MenuText);
- }
-
- if (windowStyle & FW_kHasMaximizeBox)
- {
- bedrock->LoadString(IDSL_SYSTEMMENU, IDS_MAXIMIZE, MenuText);
- ::AppendMenu(fMenuHandle, wfItemFlags, SC_MAXIMIZE, MenuText);
- }
-
- ::AppendMenu(fMenuHandle, MF_SEPARATOR, 0, NULL);
-
- {
- bedrock->LoadString(IDSL_SYSTEMMENU, IDS_CLOSE, MenuText);
- ::AppendMenu(fMenuHandle, wfItemFlags, SC_CLOSE, MenuText);
- }
- }
- #endif
- }
- #endif
-
-